<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PC通讯录</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="refresh" content="1200">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css"/>
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=86e2297f">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=222aea35">
    <!-- Bootstrap 3.3.6 -->
    <style type="text/css">
        [v-cloak] {
            display: none;
        }
        .selectOption{
            margin-right: 20px;
        }
        .selectOption span{
            color:rgb(34,139,238);
            font-weight: bold;
            cursor: pointer;
        }
        /*table td:nth-child(2){*/
        /*color:#2a8cec !important;*/
        /*}*/
        /* .red td{color:red !important;}*/
        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;    outline: none;
        }
        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            color: #333 !important;
            text-align: left !important;
        }
        .td-value {
            text-align: center !important;
            vertical-align: middle;
            word-wrap: break-word;
            color: black !important;
        }

        .td-value span {
            /*display: inline-block;*/
            overflow: hidden;
            padding-left: 0.06rem;
            word-wrap: break-word;
            color: black !important;
        }
        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
        .fixed-table_body tr td {
            border-right: none;
            font-size: 12px;
            text-align: center;
        }

        .fixed-table_header tr th {
            border-right: none;
            background: yellow;
            font-weight: normal;
            font-size: 12px;
        }
        .fixed-table_body tr:nth-of-type(even){
            background: #F9F9F9;
        }
        .slide-box {
            display: -webkit-box;
            -webkit-overflow-scrolling: touch;
            height: 34px;
            line-height: 34px;
            /*background: #2a8cec;*/
            width: 100%;
            padding-left: 5px;
            border-bottom: 1px solid #989898;
        }
        .rights {
            text-align: center;
            color: #000;
            font-size: 14px;
            margin-left: 8px;
            margin-right: 8px;
            margin-top: 3px;
            cursor: pointer;
        }
        .lefts {
            text-align: center;
            color: #fff;
            /*background-image: url(/dist/img/tabApp.png);*/
            margin-left: 8px;
            margin-right: 8px;
            /*background-size: 100% 100%;*/
            padding: 4px 15px 3px 15px;
            background: #228bee;
            z-index: 999;
            border-top-left-radius: 3px;
            border-top-right-radius: 3px;
        }
        .slide-box1 {
            display: -webkit-box;
            /* overflow-x: scroll; */
            overflow-y: hidden;
            -webkit-overflow-scrolling: touch;
            height: 30px;
        }
        .right {
            text-align: center;
            color: #666666;
            font-size: 12px;
            /* border-bottom: 2px solid #f8f8f8; */
            margin-left: 4px;
            margin-right: 4px;
            padding-top: 10px;
            padding-bottom: 5px;
            cursor: pointer;

        }
        .left {
            text-align: center;
            color: #228bee;
            /*border-bottom: 2px solid #228bee;*/
            margin-left: 8px;
            margin-right: 8px;
            padding-bottom: 5px;
        }
        .tryStyle {
            width: 34px;
            height: 17px;
            line-height: 17px;
            font-size: 12px;
            top: -1px;
            right: -10px;
            position: absolute;
            border-radius: 50px;
            margin-top: 4px;
            background: #FF0000;
            color: #fff;
            margin-right: -2px;
            transform: scale(0.7);
            text-align: center !important;

        }
        .content {
            padding: 8px 8px 0 8px;
        }
    </style>
</head>
<body>
<section v-cloak id="app" class="content">
    <div class="div-td-content-more"><i></i></div>
    <iframe id="ifExprot" style="width:0px;height:0px;display: none;" frameborder="0"></iframe>
    <!--<div style="overflow: hidden;top: 0;left: 0;width: 100%;position: relative;border-bottom: 1px solid #2a8cec;">-->
        <!--<div style="width: 45px;position:absolute;top: 0;left: 0;margin-right: 45px;height: 45px;background: #2a8cec;" v-if="companyList&&companyList.length>0"></div>-->
        <div class="slide-box">
            <div v-for="(item,i) in companyList" class="rights">
                <span :class="selectCompany==i? 'lefts':'rights'" style="height: 30px"
                      @click="selectCompany=i;get_departList(item)">
                    {{item.name}}
                </span>
            </div>
        </div>
        <!--只李丽平有-->
        <input type="button" class="btn btn-sm pull-right" value="导出通讯录"
               @click="exportAll()" style="position:absolute;right: 22px;top: 22px;color: #fff !important;background: #fff;"
               v-if="userId=='2017121616084F0B9E200AC4144BD435'"/>
    <!--</div>-->
    <!--获取部门-->
    <div style="position: relative;">
        <div class="slide-box1">
            <div v-for="(item,i) in departList" class="right">
                <span :class="selectDepart==i? 'left':'right'" style="height: 30px"
                      @click="selectDepart=i;getAll(item.id)">
                    {{item.name}}
                </span>
            </div>
        </div>
        <div style="position: absolute;right:85px;top:2px" v-if="isShowBtn('exportPhone')">
            <div class="has-feedback">
                <input id="searchKey" type="text" class="form-control input-sm"
                       placeholder="请输入姓名或电话"   v-model="key"  autocomplete="off" style="width:250px;">
                <span id="btnQuery"
                      class="glyphicon glyphicon-search form-control-feedback" @click="get_search()"></span>
            </div>
        </div>
        <div style="position: absolute;right:0px;top:2px" v-else>
            <div class="has-feedback">
                <input id="searchKey" type="text" class="form-control input-sm"
                       placeholder="请输入姓名或电话"   v-model="key"  autocomplete="off" style="width:250px;">
                <span id="btnQuery"
                      class="glyphicon glyphicon-search form-control-feedback" @click="get_search()"></span>
            </div>
        </div>
        <div style="position: absolute;right: 0px;top:2px">
            <input type="button" class="btn oaBtn btn-sm pull-right" value="导出通讯录"
                   @click="exportGet()" v-if="isShowBtn('exportPhone')"/>
        </div>
    </div>

    <div class="box-body no-padding iframePhone" style="overflow: auto;" id="scrollDiv">
        <div id="progress" class="wyui-progress"></div>
        <div class="fixed-table-box head-fixed ">
            <div class="fixed-table_header-wraper">
                <table class="fixed-table_header "  cellspacing="0" cellpadding="0" border="0">
                    <thead>
                    <tr>
                        <th style="width: 80px;"><div class="table-cells">姓名</div></th>
                        <th style="width: 100px;"><div class="table-cells">电话</div></th>
                        <th style="width: 100px;"><div class="table-cells">小号</div></th>
                        <th style="width: 80px;"><div class="table-cells" style="text-align: left !important;">部门</div></th>
                        <th style="width: 100px;"><div class="table-cells" style="text-align: left !important;">职位</div></th>
                        <th style="width: 200px;"><div class="table-cells" style="text-align: left !important;">邮箱</div></th>
                        <th ><div class="table-cells" style="text-align: left !important;">区域</div></th>
                        <th style="width: 50px;"><div class="table-cells" style="text-align: left !important;">年龄</div></th>
                        <th style="width: 100px;"><div class="table-cells" style="text-align: left !important;">学历</div></th>
                        <th style="width: 100px;"><div class="table-cells" style="text-align: left !important;">车牌</div></th>
                        <th style="width: 17px;"><div class="table-cells"></div></th>
                    </tr>
                    </thead>
                </table>
            </div>
            <div class="fixed-table_body-wraper iframePhoneFixed ">
                <table class="fixed-table_body table-hover" cellspacing="0" cellpadding="0" border="0"
                       style="width: 100%;">
                    <tbody>
                    <tr v-for="(item,i) in list" :class="item.jobState<0?'red':''">
                        <!--<td   style="width: 80px" >-->
                        <!--{{item.name}}-->
                        <!--<span v-if="item.jobState === -2" style="color: #fff !important;"-->
                        <!--class="tryStyle">试岗</span>-->
                        <!--<span style="background:#FFA500;color: #fff !important;"-->
                        <!--v-else-if="item.jobState === -1"-->
                        <!--class="tryStyle">试用</span>-->
                        <!--<span v-else></span>-->
                        <!--</td>-->
                        <td class="td-value" style="width: 80px;" v-if="getQuanXian(item.id)">
                        <span style="color: #2a8cec !important;text-align: justify;display: inline-block;overflow: hidden;vertical-align: middle;height: 24px;line-height: 24px;width: 40px;cursor: pointer;" @click="lookInfo(item)">
                            {{item.name}}<i style="display: inline-block;width: 100%;height: 0;"></i>
                        </span>
                            <span v-if="item.jobState === -2" style="color: #fff !important;"
                                  class="tryStyle">试岗</span>
                            <span style="background:#FFA500;color: #fff !important;"
                                  v-else-if="item.jobState === -1"
                                  class="tryStyle">试用</span>
                            <span v-else></span>
                        </td>
                        <td class="td-value" style="width: 80px;" v-else>
                        <span style="text-align: justify;display: inline-block;overflow: hidden;vertical-align: middle;height: 24px;line-height: 24px;width: 40px;">
                            {{item.name}}<i style="display: inline-block;width: 100%;height: 0;"></i>
                        </span>
                            <span v-if="item.jobState === -2" style="color: #fff !important;"
                                  class="tryStyle">试岗</span>
                            <span style="background:#FFA500;color: #fff !important;"
                                  v-else-if="item.jobState === -1"
                                  class="tryStyle">试用</span>
                            <span v-else></span>
                        </td>
                        <td  style="width: 100px">
                            {{item.tel}}
                        </td>
                        <td class="text-center" style="width: 100px">
                            {{item.trumpet}}
                        </td>
                        <td class="text-center" style="width:80px;text-align: left;">
                            {{item.departName}}
                        </td>
                        <td class="text-center" style="width:100px;text-align: left;">
                            {{item.roleName}}
                        </td>
                        <td style="text-align: left!important;width: 200px;">
                            {{item.email}}
                        </td>
                        <td class="text-center td-value" >
                            <span class="lineOne">{{item.regionName}}</span>
                        </td>
                        <td class="text-center td-value" style="text-align: left!important;width: 50px;">
                            {{item.ageNumber}}
                        </td>
                        <td class="text-center td-value" style="text-align: left!important;width: 100px;">
                            <span class="lineOne">{{item.education}}</span>
                        </td>
                        <td class="text-center" style="width:100px;text-align: left!important;">
                            {{item.carCard}}
                        </td>
                        <template v-if="list.length>=18">
                            <td style="width: 0px;"></td>
                        </template>
                        <template v-else>
                            <td style="width: 17px;" ></td>
                        </template>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>

    </div>
    <div  style="text-align: center;bottom: 0;left: 0;width: 100%;background-color:white;position: relative">
        <div>
            <span class="pd_1"> 公司合计：<strong>{{jobStates.companyNum}}</strong>人</span>
            <span class="pd_1"> 部门合计：<strong>{{jobStates.departNum}}</strong>人</span>
        </div>
    </div>
</section>

<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=0b5caf39"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=0c4d95a9"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/plugins/fixedTable/fixed-table.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    var query = null;
    var app = new Vue({
        el: '#app',
        data: {
            userId: getCurrentUser().id,
            jobState: '',
            jobStates:{},
            key: '',
            rightOp: [],//权限列表
            searchParams: {
                selectCom: "",
                userId: getCurrentUser().id,
                key: '',
                companyId:$.wyui.page.urlParams.companyId ? $.wyui.page.urlParams.companyId : getCurrentUser().id,
            },
            ip:"",
            companyList: [],
            departList:[],
            list: [],
            list2: [],
            selectDepart: 0,
            selectCompany: 0
        },
        methods: {
            isHasRightOp: function (eName) {
                return $.inArray(eName, this.rightOp) > -1;
            },
            isShowBtn: function (eName) {
                if (getCurrentUser().superUser || this.isHasRightOp(eName)) {
                    return true;
                } else {
                    return false;
                }
            },
//            通讯录导出
            exportGet: function () {
                var that = this;
                $.dialog({
                    content: 'url:/page/PCPhonebook/chooseExportGetField.html?companyId=' + that.departList[0].companyId,
                    title: '选择导出字段',
                    width: 999,
                    height: 460,
                    max: true,
                    min: true,
                    lock: true
                });
            },
//            只李丽平可导出公司所有
            exportAll:function () {
                var that = this;
                $.dialog({
                    content: 'url:/page/PCPhonebook/chooseExportAllList.html',
                    title: '选择导出字段',
                    width: 999,
                    height: 460,
                    max: true,
                    min: true,
                    lock: true
                });
            },
            get_search: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.user.getContacts, {
                    key: that.key,
                }, function (data) {
                    console.log(data)
                    that.list = data.records;
                });
//                clearTimeout(query);
//                query = setTimeout(function () {
//                    $.wyui.postMethod(urlConfig.system.user.getContacts, {
//                        key: that.key,
//                    }, function (data) {
//                        console.log(data)
//                        that.list = data.records;
//                    });
//                }, 1000);
            },
            changeJobStates: function (jobState) {
                var that = this;
                //表格
                var data = {
                    userId:that.userId,
                    key: '',
                    jobState:jobState
                };
                $.ajax({
                    url: server.ip + urlConfig.system.user.getContacts,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (r) {
//                      var that=this;
////                    console.log(r);
                        that.list = that.tablesMergeCell(r.data.sendData.records);
                        that.jobStates=r.data.sendData.jobStates;
                    },
                    error: function (e) {
                        alert(e.responseText)
                    }
                });
            },
            getList: function () {
                var that = this;
                $.wyui.postMethod("/user/getContacts.json",
                    {userId:that.searchParams.userId,key: that.searchParams.key,companyId: that.searchParams.selectCom},
                    function (data){
                        that.list = that.tablesMergeCell(data.records);
                        that.jobStates = data.jobStates;
                    });
            },
            //打开基本信息
            lookInfo: function (item) {
                var that = this;
                top.addTabs({
                    id: item.id,
                    title: item.name + "详情",
                    close: true,
                    url: '/personnel/entry.html?id=' + item.id
                });
            },
            //获取部门
            get_departList: function (item) {
                var that = this;
                if (that.userId == '20181225140445CD827D94AF9A96C367') {
                    if (item.ggxq) {
                        //ggxq
                        that.ip = "http://39.106.135.205/jsyf-oa"
                    } else {
                        //wy
                        that.ip = "http://39.106.158.158:8080/jsyf-oa"
                    }
                }
                $.ajax({
                    url: that.ip + "/depart/getByCompanyId.json",
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify({"companyId": item.id}),
                    success: function (r) {
                        that.departList = r.data.sendData;
                        console.log(r)
                        that.selectDepart = 0;
                        that.getAll(that.departList[0].id);
                    }
                });
            },
            //获取列表
            getAll: function (departId) {
                console.log("1")
                var that = this;
                that.key = '';
                var data = {
                    userId: that.userId,
                    key: '',
                    jobState: "",
                    departId: departId
                };
                $.ajax({
                    url: that.ip + urlConfig.system.user.getContacts,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify(data),
                    success: function (r) {
//                        var res = JSON.parse(r);
                        that.list = r.data.sendData.records;
                        that.jobStates = r.data.sendData.jobStates;
                        console.log(r);
                    },
                    error: function (e) {
                        alert(e.responseText)
                    }
                });
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },
            //阎总要看到滚滚所有
            get_companyGGXQ: function () {
                var that = this;
                $.ajax({
                    url: "http://39.106.135.205/jsyf-oa" + urlConfig.system.company.getCompanyList,
                    contentType: 'application/json;charset=utf-8',
                    type: "POST",
                    data: JSON.stringify({userId: "201711271733404C9DA1461F2421F828"}),
                    success: function (r) {
                        console.log(r)
                        var data = r.data.sendData;
                        for (var i = 0; i < data.length; i++) {
                            data[i].ggxq = 1;
                            that.companyList.push(data[i])
                        }
                        that.get_departList(that.companyList[0]);
                    }
                });
            },
            //获取查看个人信息权限
            getPower: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.user.getSubordinateByParentId, {
                    userId: that.userId
                }, function (data) {
                    var ids = [];
                    that.list2 = data;
                    for(var i=0;i<that.list2.length;i++){
                        ids.push(that.list2[i].id)
                    }
                    that.listQX = ids;
                },true);
            },
            getQuanXian:function (id) {
                return $.inArray(id,this.listQX) > -1;
            },
            //获取导出权限功能
            getRightOpByUserId:function () {
                var that = this;
                $.wyui.postMethod(urlConfig.system.rightOp.getRightOpByUserId, {
                    userId: getCurrentUser().id
                }, function (rightOp) {
                    for (var i = 0; i < rightOp.length; i++) {
                        that.rightOp.push(rightOp[i].eName);
                    }
                    console.log("权限列表如下：")
                    console.log(that.rightOp);
                });
            }

        },
        mounted: function () {
            var that = this;
            that.getPower();
            that.getRightOpByUserId();
            that.ip = server.ip;
            $.ajax({
                url: that.ip + urlConfig.system.company.getCompanyList,
                contentType: 'application/json;charset=utf-8',
                type: "POST",
                data: JSON.stringify({userId: that.userId}),
                success: function (r) {
                    console.log(r)
//                    var res = JSON.parse(r);
                    if (that.userId == '20181225140445CD827D94AF9A96C367') {
                        <!--阎俊伟 滚滚向前和沃源通讯录都能看到-->
                        that.companyList = r.data.sendData;
                        that.get_companyGGXQ();
                    } else {
                        that.companyList = r.data.sendData;
                        that.get_departList(that.companyList[0]);
                    }
                    that.selectCompany = 0
                    console.log(that.companyList)

                },
                error: function (e) {
                    alert(e.responseText)
                }
            });
        }
    });
</script>
<script>
    //初始化FixedTable
    $(".fixed-table-box").fixedTable();
    $(function () {
        $("#searchKey").autoComplete({
            url: server.ip + urlConfig.system.user.getTop10ByNameUser,
            render: function (users, panel) {
                console.log("users=" + users);
                if (users) {
                    for (var i = 0; i < users.length; i++) {
                        $("<li></li>").data("autoComplete",
                            users[i]).html("<a>" + users[i].name + "&nbsp;&nbsp;&nbsp;" +
                            "(" + "&nbsp;" + users[i].companyName + "-" + users[i].departName + "-" + users[i].roleName + "&nbsp;" + ") " + "</a>")
                            .appendTo(panel);
                    }
                }else{
                    console.log("2");
                    $(".wyui-autocomplete-panel").hide();
                }
            },
            selected: function (user) {
                app.key=user.name;
                app.get_search();
                $(this).val("");
                return false;
            },
            height: 210,
            width: 250
        });
    });
    $("#searchKey").keypress(function (e) {
        if (event.keyCode == 13) {
            event.cancelBubble = true;
            event.returnValue = false;
            $("#btnQuery").click();
        }
    });
</script>

</body>
</html>